﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Spaanjaars.ContactManager.Infrastructure.UnitOfWork;
using Spaanjaars.ContactManager.Model;
using Spaanjaars.ContactManager.Services.Interfaces;
using StructureMap;
using StructureMap.Configuration.DSL;

namespace Spaanjaars.ContactManager.UX.MVC
{
    public class BootStrapper
    {
        public static void ConfigureDependencies()
        {
            ObjectFactory.Initialize(x =>
            {
                x.AddRegistry<ControllerRegistry>();

            });
        }

        public class ControllerRegistry : Registry
        {
            public ControllerRegistry()
            {
                ForRequestedType<IContactPersonCreationService>().TheDefault.Is.OfConcreteType
                         <Services.Implementations.ContactPersonCreationService>();                
                
                ForRequestedType<IContactPersonSearchService>().TheDefault.Is.OfConcreteType
                    <Services.Implementations.ContactPersonSearchService>();  

                // NHibernate
                ForRequestedType<IContactPersonRepository>().TheDefault.Is.OfConcreteType
                         <Spaanjaars.ContactManager.Repository.NH.ContactPersonRepository>();
                ForRequestedType<IUnitOfWork>().TheDefault.Is.OfConcreteType
                         <Spaanjaars.ContactManager.Repository.NH.NHUnitOfWork>();                


                // Enity Framework
                //ForRequestedType<IContactPersonRepository>().TheDefault.Is.OfConcreteType
                //         <Spaanjaars.ContactManager.Repository.EF.ContactPersonRepository>();
                //ForRequestedType<IUnitOfWork>().TheDefault.Is.OfConcreteType
                //         <Spaanjaars.ContactManager.Repository.EF.EFUnitOfWork>(); 
            }
        }
    }
}